﻿@model string
<div class="main">
    <table border=0 cellpadding=0 cellspacing=0 class="table table-bordered form-inline form-group-sm" id="tb_list">
        <thead>
            <tr>
                <td style="width:45px">选择</td>
                <td align="center">目标分类</td>
            </tr>
        </thead>
        <tr>
            <td align="center"><input type="radio" value="0" class="checked-item"></td>
            <td align="center" style="text-align:left">一级分类</td>
        </tr>
        <tr class="item list-template-item parent_{parentGuid}" id="item_{id}" data-id="{id}" data-parentId="{parentId}" data-isFinal="{isFinal}">
            <td align="center"><input type="radio" id="id" name="id" value="{id}" class="checked-item checked-item-{id} final_{isFinal}"></td>
            <td align="center" style="text-align:left">{space}<span class="node node_{isFinal}"></span><span>{name}</span></td>
        </tr>
    </table>
    <div class="footerarea">
        提示：请选择要转移的目标分类！
    </div>

    <div class="submit-footerbar">
        <label class="control-label"></label>
        <div class="controls">
            <form class=" form-group-sm form ui-validForm" method="post">
                <input type="hidden" name="targetId" id="targetId" value="0" />
                <input type="hidden" name="ids" id="ids" value="@Request.QueryString["ids"]" />
                    <button type="button" class="btn btn-primary ui-pagePost btn-sm" data-custom-params="url:'@Url.ActionUrl()',callBack:'PostBack',beforeExecute:'BeforeExecuting'">转移</button>
                    <button type="button" class="btn btn-default ui-closeDialog btn-sm">关闭</button>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">

    function SetIds() {
        var $ids = $("#ids");
        var $parentIds = parent.$(".checked-item");
        var ids = $parentIds.GetChecked();
        var arrIds = ids.split(",");
        for (var i = 0; i < arrIds.length; i++) {
            $(".checked-item-" + arrIds[i]).attr("disabled", "disabled");
        }
        $ids.val(ids)
    }


    function LoadedInit()
    {
        SetIds();
        $(".final_1").attr("disabled", "disabled");
    }


    var jsonUrl ="@Url.ActionUrl("ListData")?table=@Request.QueryString["table"]";
    $("#tb_list").TreeBind({url:jsonUrl,callBack: "LoadedInit",showFooter:false});

    function BeforeExecuting() {
        var id = $(".checked-item").GetChecked();
        if (id == "") {
            Alert("请选择要转移的目标分类!")
            return false;
        }
        $("#targetId").val(id);
        return true;
    }
</script>